

namespace recognition {

    //% block="百度大脑：【手写文字识别】初始化[apikey][secretkey]" blockType="command"
    //% apikey.shadow="string" apikey.defl="apikey"   
    //% secretkey.shadow="string" secretkey.defl="secretkey"   
    export function handwritingInit(parameter: any, block: any) {
        let apikey=parameter.apikey.code;
        let secretkey=parameter.secretkey.code;
        Generator.addImport(`import base64`)
        Generator.addImport(`import requests`)
        Generator.addImport(`apikey=${apikey}`)
        Generator.addImport(`secretkey=${secretkey}`)
    }    
   

    //% block="识别图中[image]包含的手写文字 " blockType="reporter"
    //% image.shadow="string" image.defl=".jpg"   
    export function handwriting(parameter: any, block: any) {
        let image =parameter.image.code;
        Generator.addImport(`import handwriting`)
        Generator.addCode(`handwriting.AIBaiDu_handwriting_POST(${image},apikey,secretkey)`)
    }
    //% block="从摄像头画面截取图片 " blockType="reporter"
    export function handwriting_camera(parameter: any, block: any) {
        Generator.addImport(`import handwriting`)
        Generator.addCode(`handwriting.capture_and_recognize_text(apikey,secretkey)`)
    }
  
   


  
}

